<template>
  <el-card class="app-container">
    <c-u-r-d-table :option="option" ref="table"/>
  </el-card>
</template>

<script>

import ColumnType from '@/framework/constant/ColumnType'
import {shopGoodsApi} from '@/feature/lms/infra/api/shopGoodsApi'
import CURDTable from '@/framework/components/table/CURDTable'

export default {
  name: 'ShopGoodsList',
  components: { CURDTable },
  props: {
    shopId: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      option: {
        initListParams: () => {
          return {
            shopId: this.shopId
          }
        },
        initFormParams: () => {
          return {
            shopId: this.shopId
          }
        },
        requestApi: shopGoodsApi,
        showSelection: false,
        groupId: 1,
        autoLoad: false,
        dialogWidth: '600px',
        tableHeight: 500,
        columns: [
          // {
          //   label: '商家id',
          //   prop: 'shopId',
          //   searchable: true,
          //   type: ColumnType.SELECT
          // },
          {
            label: '商品名称',
            prop: 'goodsName',
            span: 24,
            searchable: true,
            required: true
          }, {
            label: '商品封面',
            prop: 'goodsCover',
            span: 24,
            type: ColumnType.IMAGE,
            required: true
          },
          {
            label: '按钮内容',
            hiddenInTable: true,
            required: false,
            prop: 'buttonText',
            span: 24,
            type: ColumnType.TEXT
          }, {
            label: '按钮链接',
            viewAsLink: true,
            hiddenInTable: false,
            required: false,
            prop: 'buttonLink',
            span: 24,
            type: ColumnType.LINK
          },
          // {
          //   label: '价格',
          //   type: ColumnType.NUMBER,
          //   span: 24,
          //   required: true,
          //   prop: 'price'
          // },
          {
            label: '创建时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtCreate'
          },
          {
            label: '修改时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtModified'
          }
        ]
      }
    }
  },
  methods: {
    refresh() {
      this.$refs.table.reloadTable()
    }
  }
}
</script>

